<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* while(条件) {
  满足条件就执行
}*/

      // var num = 0
      // while (num < 10) {
      //   num += 1
      //   console.log(num)
      // }

      // 案例 1 求1-100的和
      var num = 1
      var sum = 0

      while (num <= 100) {
        sum += num
        num++
      }
      console.log(sum)

      // 案例 2 求一个数字的阶乘 5*4*3*2*1
      var a = 1
      var b = 1
      while (a <= 5) {
        b *= a
        a++
      }
      console.log(b)
    </script>
  </body>
</html>
